home *** CD-ROM | disk | FTP | other *** search
- Path: falcon.ukc.ac.uk!bj2
- From: bj2@ukc.ac.uk (B.Jury)
- Newsgroups: comp.lang.c++
- Subject: Random File Access (fstream)
- Date: Mon, 11 Mar 96 16:22:45 GMT
- Organization: University of Kent at Canterbury, UK.
- Message-ID: <12708@falcon.ukc.ac.uk>
- NNTP-Posting-Host: falcon.ukc.ac.uk
-
- Can anyoe please tell me why the following program does not work at all??
-
- int test(int pos) {
- datastruct temp;
-
- ofstream output("File.Bin",ios::ate);
- if (!output) { return 1; }
-
- output.seekp(pos*sizeof(temp));
-
- output.write((char *)&temp,sizeof(temp));
-
- output.close();
- return 0;
- }
-
- tellp() reports the pointer is at the coprrect place, and eof() also
- is OK, so why doesnt output.write write to the file?!? Ive hunted
- on the WWW, cant find any example code, so any help would be apreciated.
-
- Regards,
- -Ben.
- --
- \ \\ B.Jury - University Of Kent. PAL PSeX Owner. Wanna trade games? // /
- \ \\ Frontier - First Encounters Black Space Patch available on request. // /
- \ \\ Opinions are my own, and maybe yours, if not i dont care :) // /
- \ \ \\ * Dammit, keep posts to 75 chars wide, for us poor unixers. * // / /
-